package com.yanqu.road.server.cmd.group.rank;

import com.yanqu.road.pb.grandchild.GrandChildProto;
import com.yanqu.road.server.cmd.CrossCommand;
import com.yanqu.road.server.command.Cmd;
import com.yanqu.road.server.logic.MessageHelper;
import com.yanqu.road.utils.YanQuMessageUtils;
import com.yanqu.road.message.YanQuMessage;
import com.yanqu.road.server.protocol.CrossProtocol;
import com.yanqu.road.server.protocol.Protocol;


@Cmd(code = CrossProtocol.C_GET_GRAND_CHILD_RANK_DETAIL_INFO_RETURN, desc = "从区服获取孙子榜单孙子详细信息")
public class CrossGrandChildRankDetailInfoReturnCmd extends CrossCommand {
    private GrandChildProto.GrandChildRankDetailInfoCrossRespMsg reqMsg;
    @Override
    public boolean parseData(YanQuMessage packet) throws Exception {
        reqMsg = GrandChildProto.GrandChildRankDetailInfoCrossRespMsg.parseFrom(packet.getBytes());
        return true;
    }

    @Override
    public void execute(YanQuMessage packet) throws Exception {
        GrandChildProto.GrandChildRankDetailInfoRespMsg.Builder respMsg = GrandChildProto.GrandChildRankDetailInfoRespMsg.newBuilder();
        respMsg.setRet(reqMsg.getRet());
        if(0 == reqMsg.getRet()){
            respMsg.setGrandChild(reqMsg.getGrandChild().toBuilder());
        }
        YanQuMessage pbMsg = YanQuMessageUtils.buildMessage(Protocol.U_GET_GRAND_CHILD_RANK_DETAIL_INFO, respMsg);
        MessageHelper.sendPacket(reqMsg.getFromServerId(), reqMsg.getFromUserId(), pbMsg);
    }

    @Override
    public void sendData() {

    }
}
